package com.liang.exception;

public class ExceptionDemo2 {
    public static void main(String[] args) {
        int[] arr = null;
        try {
            int a = 5;
            printArr(arr);
        } catch (NullPointerException e) {

            e.printStackTrace();
            System.out.println("参数不正确");

        }

        System.out.println("嘿嘿嘿");

    }

    public static void printArr(int[] arr) {
        if (arr == null) {
            throw new NullPointerException();
        }else{

        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);

        }
        }
    }
}
